Searching and Visualizing Fatal Encounters Dataset

These tables and visualizations are generated using the Fatal Encounters Dataset from fatalencounters.org. As seen in the bar charts, this dataset ranges from 2000-2021.

Search Fatal Encounters Dataset

Entire U.S.

Code
import pandas as pd
sheet_id = "1dKmaV_JiWcG8XBoRgP8b4e9Eopkpgt7FL7nyspvzAsE"
sheet_name = "sample_1"
url = f"https://docs.google.com/spreadsheets/d/{sheet_id}/gviz/tq?tqx=out:csv&sheet={sheet_name}"
df = pd.read_csv(url)
ojs_define(fe_data = df)
Code
viewof fe_search = Inputs.search(transpose(fe_data), 
{placeholder: "Enter a name, zip code, county, city, or police department name", 
width: 900,
label: "Search FE Data"
})
Code
viewof fe_rows = Inputs.table(fe_search, {
  columns: [
    'Unique ID',
    'Name',
    'Age',
    'Gender',
    'Race',
    'Race with imputations',
    'Imputation probability',
    'URL of image (PLS NO HOTLINKS)',
    ' Date of injury resulting in death (month/day/year)',
    'Location of injury (address)',
    'Location of death (city)',
    'State',
    'Location of death (zip code)',
    'Location of death (county)',
    'Full Address',
    'Latitude',
    'Longitude',
    'Agency or agencies involved',
    'Highest level of force',
    'UID Temporary',
    'Name Temporary',
    'Armed/Unarmed',
    'Alleged weapon',
    'Aggressive physical movement',
    'Fleeing/Not fleeing',
    'Description Temp',
    'URL Temp',
    'Brief description',
    'Intended use of force (Developing)',
    'Supporting document link',
  ],
  format: {
    'Unique ID': x => x.toFixed(0),
    'Location of death (zip code)': x => x.toFixed(0),
    'Supporting document link': x => htl.html`<a href=${x} target=_blank>${x}</a>`,
    'URL of image (PLS NO HOTLINKS)': x => htl.html`<a href=${x} target=_blank>${x}</a>`
  },
})

California Only

Code
ca_only = transpose(fe_data).filter(function(p) {
  return p.State === 'CA';
})
Code
viewof fe_ca_search_all_cols = Inputs.search(ca_only, 
{placeholder: "Enter a name, zip code, county, city, or police department name", 
width: 900,
label: "Search FE Data (CA only)"
})
Code
viewof fe_rows_ca_all_cols = Inputs.table(fe_ca_search_all_cols, 
{
  columns: [
    'Unique ID',
    'Name',
    'Age',
    'Gender',
    'Race',
    'Race with imputations',
    'Imputation probability',
    'URL of image (PLS NO HOTLINKS)',
    ' Date of injury resulting in death (month/day/year)',
    'Location of injury (address)',
    'Location of death (city)',
    'State',
    'Location of death (zip code)',
    'Location of death (county)',
    'Full Address',
    'Latitude',
    'Longitude',
    'Agency or agencies involved',
    'Highest level of force',
    'UID Temporary',
    'Name Temporary',
    'Armed/Unarmed',
    'Alleged weapon',
    'Aggressive physical movement',
    'Fleeing/Not fleeing',
    'Description Temp',
    'URL Temp',
    'Brief description',
    'Intended use of force (Developing)',
    'Supporting document link',
  ],
  format: {
    'Unique ID': x => x.toFixed(0),
    'Location of death (zip code)': x => x.toFixed(0),
    'Supporting document link': x => htl.html`<a href=${x} target=_blank>${x}</a>`,
    'URL of image (PLS NO HOTLINKS)': x => htl.html`<a href=${x} target=_blank>${x}</a>`
  },
} 
)
Code
tidy_w_race = transpose(fe_data).map(d => ({date: new Date(d[' Date of injury resulting in death (month/day/year)']).getFullYear(), count: 1, race: d.Race, state: d.State}))

Preliminary FE Data Visualizations

Entire U.S.

The plot below visualizes the number of fatal encounters per year for all of the United States.

Code
Plot.plot({
  width: 928,
  height: 500,
  x: {tickFormat: ""},
  y: {tickSpacing: 50},
  color: {legend: true},
  marks: [
  Plot.barY(tidy_w_race, {x: 'date', y: 'count', fill: 'race', sort: 'race'}),
  ]
})

The plot below visualizes the number of fatal encounters per year for all of the United States separated by state.

Code
tidy_no_race = tidy_w_race.map(d => ({date: d.date, count: d.count, state: d.state}))
Code
viewof fe_search_by_state = Inputs.search(tidy_no_race, 
{placeholder: `Enter an abbreviated state name (i.e. for California, type "CA")`, 
width: 900,
label: "Search by state"
})
Code
Plot.plot({
  width: 928,
  height: 500,
  x: {tickFormat: ""},
  y: {tickSpacing: 50},
  color: {legend: true},
  marks: [
  Plot.barY(fe_search_by_state, {x: 'date', y: 'count', fill: 'state', sort: 'state'}),
  ]
})

California Only

The plot below visualizes the number of fatal encounters per year for California only.

Code
ca_only_tidy = ca_only.map(p => ({name: p.Name, date: new Date(p[' Date of injury resulting in death (month/day/year)']).getFullYear(), count: 1, race: p.Race, lea: p['Agency or agencies involved']}))
Code
viewof fe_ca_search = Inputs.search(ca_only_tidy, 
{placeholder: "Enter a name, year, race, or police department name", 
width: 900,
label: "Search Fatal Encounter Dataset (CA only)"
})
Code
viewof fe_rows_ca = Inputs.table(fe_ca_search, 
{
  columns: [
    'name',
    'date',
    'race',
    'lea',
  ],
  format: {
    date : x => x.toFixed(0),
    // 'Location of death (zip code)': x => x.toFixed(0),
    // 'Supporting document link': x => htl.html`<a href=${x} target=_blank>${x}</a>`,
    // 'URL of image (PLS NO HOTLINKS)': x => htl.html`<a href=${x} target=_blank>${x}</a>`
  },
} 
)
Code
Plot.plot({
  width: 1000,
  height: 600,
  x: {tickFormat: ""},
  y: {tickSpacing: 50},
  color: {legend: true},
  marks: [
  Plot.barY(fe_ca_search, {x: 'date', y: 'count', fill: 'race', sort: 'race'}),
  ]
})